﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BioBookClientSkole.ServiceReference1;
using System.Data.SqlClient;
using System.Threading;
using System.Globalization;

namespace BioBookClientSkole
{
    public static class Program
    {
        static ServiceReference1.BioBookServiceClient BioBookService = new ServiceReference1.BioBookServiceClient();
        public static BioBookConnectionClass Book = new BioBookConnectionClass();


        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        public static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());

        }



        public static List<Show> findAllShows()
        {
            List<Show> show = new List<Show>();
            foreach (Show s in BioBookService.findAllShows())
            {
                show.Add(s);
            }
            return show;
        }

        public static List<Person> findAllPerson()
        {
            List<Person> pers = new List<Person>();
            foreach (Person p in BioBookService.findAllPerson())
            {
                pers.Add(p);
            }

            return pers;
        }

        public static List<Reservation> findAllReservations()
        {
            List<Reservation> res = new List<Reservation>();
            foreach (Reservation r in findAllReservations())
            {
                res.Add(r);
            }
            return res;
        }

        public static List<Movie> findAllMovie()
        {
            List<Movie> movie = new List<Movie>();
            foreach (Movie m in findAllMovie())
            {
                movie.Add(m);
            }
            return movie;
        }

        //public static List<ShowRoom> findAllShowRoom()
        //{
        //    List<ShowRoom> sh = new List<ShowRoom>();
        //    foreach(ShowRoom s in Book.findAllShowRooms())
        //    {
        //        sh.Add(s);
        //    }
        //    return sh;
        //}

        

        public static void updateShow(string dato, int showId, int showRoomNumber, string movie)
        {
         
            ShowRoom showRoomObj = BioBookService.findShowRoom(showRoomNumber);
            Movie movieObj = BioBookService.findMovie(movie);
            Show show = new Show();
            //DateTime dts = DateTime.ParseExact(dt, format, ci);
            show.showTime = dato ;
            show.movie.Title = movieObj.Title;
            show.showroom.showRoomNumber = showRoomObj.showRoomNumber;
            show.showId = showId;
            Book.UpdateShow(show);

            

        }

        public static List<Show> DataGridViewShow()
        {
            List<Show> s = new List<Show>();

            
            foreach (Show show in Book.findAllShows())
            {
                s.Add(show);
            }
            return s;
            }
            
        

        public static List<ShowRoom> DataGridViewShowRoom()
        {
            List<ShowRoom> sh = new List<ShowRoom>();
            foreach (ShowRoom s in Book.findAllShowRooms())
            {
                sh.Add(s);
            }
            return sh;
        }

        public static List<Movie> DataGridViewMovie()
        {
            List<Movie> movie = new List<Movie>();
            foreach (Movie m in Book.findAllMovie())
            {
                movie.Add(m);
            }
            return movie;
        }

        public static void createShow(int showid, string dato, string title, string movielength, string movieDes,ShowRoom showR)
        {
            Movie m = new Movie();
            m.Title = title;
            m.MovieDescription = movieDes;
            m.MovieLength = movielength;
            BioBookService.createShow(m, showR, showid, dato);
        }





    }
}
